package com.timzer.web;

import com.timzer.entity.UserEO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@RestController
@Api(tags = "用户管理",  value = "用户管理")
public class UserCtrl {

    @GetMapping("/all")
    @ApiOperation(value = "获取所有用户", notes = "备注")
    public List<UserEO> getAll(){
        List list = new ArrayList<UserEO>();
        UserEO user = new UserEO();
        user.setAge(25);
        user.setSex("女");
        user.setUsername("菜菜");
        list.add(user);
        user = new UserEO();
        user.setAge(29);
        user.setSex("男");
        user.setUsername("谢谢");
        list.add(user);
        return list;
    }

    @GetMapping("/getUser")
    @ApiOperation(value = "获取单个用户")
    public UserEO getUser(@RequestParam String username){
        return new UserEO();
    }

    @GetMapping("/index")
    @ApiOperation(value = "index")
    public ModelAndView index(){
        return new ModelAndView("index.html");
    }

    @GetMapping("/home")
    @ApiOperation(value = "首页")
    public ModelAndView home(){
        return new ModelAndView("index.html");
    }

    @GetMapping("/websocket")
    @ApiOperation(value = "websocket")
    public ModelAndView websocket(){
        return new ModelAndView("websocket.html");
    }
}
